
import cache from '@/libs/cache'
import { ACCESS_TOKEN, LOGIN_USER_INFO } from './mutation-types'

const getters = {
    language: state => state.app.language,
    asyncRoutes: state => state.permission.asyncRoutes,
    sidebar: state => state.app.sidebar,
    device: state => state.app.device,
    userInfo: state => {
        let info = state.user.userInfo
        if (info && info.username && info.token) {
            return info;
        }
        info = cache.get(LOGIN_USER_INFO);
        return info || {}
    },
    token: state => {
        let token = state.user.token
        if (token) return token;
        return cache.get(ACCESS_TOKEN);
    },
    roles: state => state.user.roles,
    errorLogs: state => state.errorLog.logs,
    size: state => state.app.size,

}

export default getters